package com.lrs.java.j2se_self.thread;

public class TestSynchronized implements Runnable{
	public int num = 0;
	
	public synchronized void m1(){
		num = 1000;
		try{
			Thread.sleep(5000);
		}catch(InterruptedException e){
			e.getMessage();
		}
		System.out.println("num1 = "+num);
	}
	public void m2(){
		System.out.println("num = "+num);
	}
	public static void main(String[] args){
		TestSynchronized tt = new TestSynchronized();
		Thread t = new Thread(tt);
		t.start();
		try{
			Thread.sleep(1000);
		}catch(InterruptedException e){
			e.printStackTrace();
		}
		tt.m2();
	}
	public void run(){
		try{
			m1();
		}catch(Exception e){
			e.printStackTrace();
		}
	}
}
